package top.huhuiyu.ds;

/**
 * 
 * @author Aiden Pearce
 *
 */
public class MyNodeDemo {

	public static void main(String[] args) {
		// 创建元素
		MyNode<String> n1 = new MyNode<String>("第一个元素");
		MyNode<String> n2 = new MyNode<String>("第二个元素");
		MyNode<String> n3 = new MyNode<String>("第三个元素");

		// 管理链接
		n1.setNext(n2);
		n2.setNext(n3);

		// 遍历节点,默认值为第一个节点，每次循环都让节点指向next，直到next为null
		for (MyNode<String> node = n1; node != null; node = node.getNext()) {
			System.out.println(node);
		}

    // 创建元素
    MyNode<Integer> ni1 = new MyNode<Integer>(100);
    MyNode<Integer> ni2 = new MyNode<Integer>(200);
    MyNode<Integer> ni3 = new MyNode<Integer>(300);

    // 管理链接
    ni1.setNext(ni2);
    ni2.setNext(ni3);

    // 遍历节点,默认值为第一个节点，每次循环都让节点指向next，直到next为null
    for (MyNode<Integer> node = ni1; node != null; node = node.getNext()) {
      System.out.println(node);
    }
	}

}
